package front

import (
	"geekai/core"
	"go.uber.org/fx"
)

// RegisterFrontHandlerObj 注册前台接口
func RegisterFrontHandlerObj() fx.Option {
	return fx.Module("front",
		fx.Provide(NewConfigHandler),
		fx.Provide(NewMenuHandler),
		fx.Provide(NewNetHandler),
		fx.Provide(NewSmsHandler),
		fx.Provide(NewUserHandler),
		fx.Provide(NewChatAppTypeHandler),
		fx.Provide(NewChatModelHandler),
		fx.Provide(NewChatRoleHandler),
		fx.Provide(NewChatItemHandler),
		fx.Provide(NewWebSocketHandler),
		fx.Provide(NewChatOpenAiHandler),
		fx.Provide(NewDallJobHandler),
		fx.Provide(NewMidJourneyHandler),
		fx.Provide(NewSdJobHandler),
		fx.Provide(NewSunoHandler),
		fx.Provide(NewVideoHandler),
		fx.Provide(NewFunctionHandler),
		fx.Provide(NewPaymentHandler),
		fx.Provide(NewInviteHandler),
		fx.Provide(NewMarkMapHandler),
		fx.Provide(NewOrderHandler),
		fx.Provide(NewPowerLogHandler),
		fx.Provide(NewProductHandler),
		fx.Provide(NewPromptHandler),
		fx.Provide(NewRealtimeHandler),
		fx.Provide(NewRedeemHandler),
		fx.Invoke(func(s *core.AppServer, h *ConfigHandler) {
			group := s.Engine.Group("/api/config/")
			group.GET("get", h.Get)
		}),
		fx.Invoke(func(s *core.AppServer, h *MenuHandler) {
			group := s.Engine.Group("/api/menu/")
			group.GET("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *NetHandler) {
			group := s.Engine.Group("/api/file/")
			group.POST("upload", h.Upload)
			group.POST("list", h.List)
			group.GET("remove", h.Remove)
			group.GET("download", h.Download)
		}),
		fx.Invoke(func(s *core.AppServer, h *SmsHandler) {
			group := s.Engine.Group("/api/sms/")
			group.POST("send_code", h.SendCode)
		}),
		fx.Invoke(func(s *core.AppServer, h *UserHandler) {
			group := s.Engine.Group("/api/user/")
			group.POST("login", h.Login)
			group.POST("register", h.Register)
			group.GET("session", h.Session)
			group.GET("logout", h.Logout)
			group.GET("profile", h.Profile)
			group.POST("profileUpdate", h.ProfileUpdate)
			group.POST("updatePass", h.UpdatePass)
			group.POST("resetPass", h.ResetPass)
			group.POST("bindMobile", h.BindMobile)
			group.POST("bindEmail", h.BindEmail)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatAppTypeHandler) {
			group := s.Engine.Group("/api/app/type/")
			group.GET("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatModelHandler) {
			group := s.Engine.Group("/api/model")
			group.GET("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatRoleHandler) {
			group := s.Engine.Group("/api/app/")
			group.GET("list", h.List)
			group.GET("list/user", h.ListByUser)
			group.POST("update", h.UpdateRole)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatItemHandler) {
			group := s.Engine.Group("/api/chat/item")
			group.GET("list", h.List)
			group.GET("detail", h.Detail)
			group.GET("remove", h.Remove)
			group.GET("history", h.History)
			group.GET("historyLastTwoMsg", h.HistoryLastTwoMsg)
			group.GET("clear", h.Clear)
			group.POST("update", h.Update)
		}),
		fx.Invoke(func(s *core.AppServer, h *WebSocketHandler) {
			s.Engine.Any("/api/chat/ws", h.Client)
		}),
		fx.Invoke(func(s *core.AppServer, h *ChatOpenAiHandler) {
			group := s.Engine.Group("/api/chat/")
			group.GET("stop", h.StopGenerate)
			group.POST("tokens", h.Tokens)
		}),
		fx.Invoke(func(s *core.AppServer, h *DallJobHandler) {
			group := s.Engine.Group("/api/dall")
			group.POST("image", h.Image)
			group.GET("jobs", h.JobList)
			group.GET("imgWall", h.ImgWall)
			group.GET("remove", h.Remove)
			group.GET("publish", h.Publish)
			group.GET("models", h.GetModels)
		}),
		fx.Invoke(func(s *core.AppServer, h *MidJourneyHandler) {
			group := s.Engine.Group("/api/mj/")
			group.POST("image", h.Image)
			group.POST("upscale", h.Upscale)
			group.POST("variation", h.Variation)
			group.GET("jobs", h.JobList)
			group.GET("imgWall", h.ImgWall)
			group.GET("remove", h.Remove)
			group.GET("publish", h.Publish)
		}),
		fx.Invoke(func(s *core.AppServer, h *SdJobHandler) {
			group := s.Engine.Group("/api/sd/")
			group.POST("image", h.Image)
			group.GET("jobs", h.JobList)
			group.GET("imgWall", h.ImgWall)
			group.GET("remove", h.Remove)
			group.GET("publish", h.Publish)
		}),
		fx.Invoke(func(s *core.AppServer, h *SunoHandler) {
			group := s.Engine.Group("/api/suno/")
			group.POST("create", h.Create)
			group.POST("update", h.Update)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
			group.GET("publish", h.Publish)
			group.GET("detail", h.Detail)
			group.GET("play", h.Play)
		}),
		fx.Invoke(func(s *core.AppServer, h *VideoHandler) {
			group := s.Engine.Group("/api/video/")
			group.POST("luma/create", h.LumaCreate)
			group.GET("list", h.List)
			group.GET("remove", h.Remove)
			group.GET("publish", h.Publish)
		}),
		fx.Invoke(func(s *core.AppServer, h *FunctionHandler) {
			group := s.Engine.Group("/api/function/")
			group.GET("list", h.List)
			group.POST("weibo", h.WeiBo)
			group.POST("zaobao", h.ZaoBao)
			group.POST("dall3", h.Dall3)
		}),
		fx.Invoke(func(s *core.AppServer, h *PaymentHandler) {
			group := s.Engine.Group("/api/payment/")
			group.POST("doPay", h.Pay)
			group.GET("payWays", h.GetPayWays)
			group.POST("notify/alipay", h.AliPayNotify)
			group.GET("notify/geek", h.GeekPayNotify)
			group.POST("notify/wechat", h.WechatPayNotify)
			group.POST("notify/hupi", h.HuPiPayNotify)
		}),
		fx.Invoke(func(s *core.AppServer, h *InviteHandler) {
			group := s.Engine.Group("/api/invite/")
			group.GET("code", h.Code)
			group.GET("list", h.List)
			group.GET("hits", h.Hits)
		}),
		fx.Invoke(func(s *core.AppServer, h *MarkMapHandler) {
			group := s.Engine.Group("/api/markMap/")
			group.POST("gen", h.Generate)
		}),
		fx.Invoke(func(s *core.AppServer, h *OrderHandler) {
			group := s.Engine.Group("/api/order/")
			group.GET("list", h.List)
			group.GET("query", h.Query)
		}),
		fx.Invoke(func(s *core.AppServer, h *PowerLogHandler) {
			group := s.Engine.Group("/api/powerLog/")
			group.POST("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *ProductHandler) {
			group := s.Engine.Group("/api/product/")
			group.GET("list", h.List)
		}),
		fx.Invoke(func(s *core.AppServer, h *PromptHandler) {
			group := s.Engine.Group("/api/prompt/")
			group.POST("lyric", h.Lyric)
			group.POST("image", h.Image)
			group.POST("video", h.Video)
		}),
		fx.Invoke(func(s *core.AppServer, h *RealtimeHandler) {
			s.Engine.POST("/api/realtime/voice", h.VoiceChat)
		}),
		fx.Invoke(func(s *core.AppServer, h *RedeemHandler) {
			group := s.Engine.Group("/api/redeem/")
			group.POST("verify", h.Verify)
		}),
	)
}
